<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/client/backgroundManagement/commons/global.jsp" %>
<c:set var="user" value="${requestScope.user}"/>  
<script type="text/javascript">
    $(function() {
    	
    	//使用EL表达式如何获取呢???
        var roleIds = "<%=  request.getAttribute("roleIds")  %>";
        var roleIdArr = null;
        if(roleIds!=''){
        	roleIdArr = roleIds.split(',')
        } 
         
        var organizationId = "<%=  request.getAttribute("organizationId")  %>" ; //字符串如何使用EL
        if(organizationId=="null"){
        	organizationId=null;
        }
        
        
        $('#organizationId').combotree({ //请求可以有有两种数据源 [] 
            url : '${path }/organizationController/tree.atrion?state=open', //state=open全部展开
            parentField : 'pid',
            lines : true,
            
           // multiple : true, //checkbox形式 可多选
          //  panelHeight : 'auto', //设置为auto时树有多长,就有多高,不带下拉条
           value : organizationId
        });

        
        $('#roleIds').combotree({
            url : '${path }/roleController/tree',
       //     parentField : 'pid',
            lines : true,
           // panelHeight : 'auto',
             // height:200,
            multiple : true,
            required : true,
            cascadeCheck : false,
            value : roleIdArr //以 逗号分隔
        });

        $('#userEditForm').form({
            url : '${path }/userController/edit',
            onSubmit : function() {
                progressLoad();
                var isValid = $(this).form('validate');
                if (!isValid) {
                    progressClose();
                }
                return isValid;
            },
            success : function(result) {
                progressClose();
                result = $.parseJSON(result);
                if (result.success) {
                    parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
                    parent.$.modalDialog.handler.dialog('close');
                } else {
                    parent.$.messager.alert('错误', result.msg, 'error');
                }
            }
        });
       // var g = '${user.status}';
       // alert(g)
       // $("#sex").val('${user.sex}');
        $("#usertype").val('${user.userType}');
       // $("#status").val('${user.status}');
    });
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'center',border:false" title="" style="overflow: hidden;padding: 3px;width:580">
        <form id="userEditForm" method="post">
            <div class="light-info" style="overflow: hidden;padding: 3px;">
               <!-- 
                <div>密码不修改请留空。</div>
                -->
            </div>
            <table class="grid">
                <tr>
                    <td>登录名</td>
                    <td><input name="id" type="hidden"  value="${user.userId}">
                    <input name="loginname" readOnly="true"   type="text" placeholder="请输入登录名称" class="easyui-validatebox" data-options="required:true,height:29" value="${user.userName}"></td>
                    <td>姓名</td>
                    <td><input name="name" readOnly="true"   type="text" placeholder="请输入姓名" class="easyui-validatebox" data-options="required:true,height:29" value="${user.displayname}"></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" readOnly="true"   name="password"/></td>
                     <td>用户类型</td>
                    <td><select id="usertype" name="userType"  class="easyui-combobox" data-options="width:150,height:29,editable:false,panelHeight:'auto'">
                            <option value="0">管理员</option>
                            <option value="1">用户</option>
                    </select></td>
                </tr>
    <!--            
                <tr>

                    <td>状态</td>
                    <td><select id="status" name="status" value="${user.status}" class="easyui-combobox" data-options="width:140,height:29,editable:false,panelHeight:'auto'">
                            <option value="1">正常</option>
                            <option value="0">停用</option>
                    </select></td>
                </tr>
      -->            
                <tr>
                    <td>部门</td>
                    <td><select id="organizationId" name="organizationId" style="width: 250px; height: 29px;" class="easyui-validatebox" data-options="required:true"></select></td>
                  </tr>
                <tr>    
                    <td>角色</td>
                    <td><input  id="roleIds" name="roleIds" style="width: 250px; height: 29px;"/></td>
                </tr>
 
            </table>
        </form>
    </div>
</div>